const fs = require("fs");

module.exports = function readDirSync(path,callback){

    var stat = fs.statSync(path)

    if(stat.isDirectory()){
        run(path)
    }else{
        callback(path)
    }


    function run(path) {
        var pa = fs.readdirSync(path);
        pa.forEach(function(ele,index){
            var info = fs.statSync(path+"/"+ele)
            if(info.isDirectory()){
                run(path+"/"+ele);
            }else{
                var filePath = path +'/'+ ele;
                callback(filePath)
            }
        })
    }
}